package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CodeBean;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.mine.model.SignUpModel;
import com.beiing.tianshuai.tianshuai.mine.model.SignUpModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.SignUpViewImpl;

/**
 * Created by Jinni on 2017/7/13 0013.
 */

public class SignUpPresenter extends BasePresenter implements SignUpPresenterImpl, SignUpModel.OnSignUpListener{

    private SignUpViewImpl mSignUpView;
    private SignUpModelImpl mSignUpModel;

    public SignUpPresenter(SignUpViewImpl signUpView) {
        mSignUpView = signUpView;
        mSignUpModel = new SignUpModel(this);
    }

    @Override
    public void getSignUpResult(String code, String number, String name, String pass, String addTime) {
        mSignUpView.showProgress();
        mSignUpModel.getSignUpResult(code, number, name, pass, addTime);
    }

    @Override
    public void getSignUpCode(String number) {
        mSignUpView.showProgress();
        mSignUpModel.getSignUpCode(number);
    }

    @Override
    public void isAlreadySignUp(String number) {
        mSignUpView.showProgress();
        mSignUpModel.isAlreadySignUp(number);
    }

    @Override
    public void onSuccess(CodeBean signUpBean) {
        mSignUpView.hideProgress();
        mSignUpView.onRequestSuccess(signUpBean);
    }

    @Override
    public void onError(Throwable e) {
        mSignUpView.hideProgress();
        mSignUpView.onRequestFailed(e);
    }

    @Override
    public void onGetCodeSuccess(CommonBean signUpBean) {
        mSignUpView.hideProgress();
        mSignUpView.getSignUpCode(signUpBean);
    }

    @Override
    public void isAlreadySignUp(CommonBean bean) {
        mSignUpView.hideProgress();
        mSignUpView.isAlreadySignUp(bean);
    }
}
